package SellCar.dao.user.impl;

import java.util.List;

import org.junit.Test;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Repository;


import SellCar.dao.user.UserMapper;
import SellCar.pojo.User;
import SellCar.utils.MyBatisUtil;
@Repository("userMapperImpl")
public class UserMapperImpl implements UserMapper{
	
	@Autowired
	@Qualifier("sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	public SqlSessionTemplate getSqlSessionTemplate() {
		return sqlSessionTemplate;
	}
	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	
	public List<User> getUserListByUserName(String userName, String password) {
		return sqlSessionTemplate.getMapper(UserMapper.class).getUserListByUserName(userName, password);
	}

	public int addUser(String userName, String password,Integer idCardno) {
		
		return sqlSessionTemplate.getMapper(UserMapper.class).addUser(userName, password, idCardno);
	}
	
	/*@Test
	public void test(){
		ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
		UserMapperImpl user = (UserMapperImpl) app.getBean("userMapperImpl");
		List<User> list = user.getUserListByUserName("admin", "admin");
		for (User user1 : list) {
			System.out.println(user1.getUserName());
		}
	}*/
}
